import { resRoutes } from '../testData/getroutes'

import request from '../axios'
function setParams(obj) {
  if (!obj) return ''
  let objList = Object.keys(obj)
  let str = ''
  objList.forEach((item, index) => {
    if (index == 0) {
      str += '?' + item + '=' + obj[item]
    } else {
      str += '&' + item + '=' + obj[item]
    }
  })
  return str
}
//登录
export const login = (data) => {
  let obj = {
    code: 0,
    msg: null,
    data: {
      role: '企业',
      userName: '测试企业',
      token: 'YHVVMealkthHvld8Db'
    }
  }
  return new Promise((resolve, reject) => {
    resolve(obj)
  })
  // return request({
  //   url: 'xhyj/user/login',
  //   method: 'post',
  //   data
  // })
}
//获取用户信息
export const getInfo = (data) => {
  let obj = {
    code: 0,
    msg: null,
    data: {
      deptName: '上海玛雅餐饮股份有限公司',
      role: '企业',
      businessId: 'E15829AEF8054D8F82F736CE28085026',
      userName: '18548',
      userId: '2931DDA2F9534BB7BBC3C26FE15E369A'
    }
  }
  return new Promise((resolve, reject) => {
    resolve(obj)
  })
  // return request({
  //   url: 'xhyj/user/userInfo',
  //   method: 'GET'
  // })
}
//获取路由列表
export const getroutes = (data) => {
  return new Promise((resolve, reject) => {
    resolve(resRoutes)
  })
  // return request({ url: 'pc/getroutes', method: 'post', data })
}
// ******************************************************************************************************
// export const getRoutineCycleList = (data) => {
//   return request({
//     url:
//       'xhyj/task/getRoutineCycleList?role=' +
//       data.role +
//       '&region=' +
//       data.region +
//       '&deptId=' +
//       data.deptId +
//       '&checkInterval=' +
//       data.checkInterval +
//       '&checkTimes=' +
//       data.checkTimes +
//       '&businessType=' +
//       data.businessType +
//       '&businessRisk=' +
//       data.businessRisk +
//       '&page=' +
//       data.page +
//       '&size=' +
//       data.size,
//     method: 'get'
//   })
// }
//获取安全检查周期列表
export const getRoutineCycleList = (data) => {
  return request({ url: 'xhyj/task/getRoutineCycleList' + setParams(data), method: 'get' })
}
//获取安全检查单位列表
export const getRoutineCheckList = (data) => {
  return request({ url: 'xhyj/task/getRoutineCheckList' + setParams(data), method: 'get' })
}
//设置安全检查周期
export const saveTaskCycle = (data) => {
  return request({ url: 'xhyj/task/saveTaskCycle', method: 'post', data })
}
//*********************************************************************
//提交专项检查任务
export const saveSpecialInspect = (data) => {
  return request({ url: 'xhyj/task/saveSpecialInspect', method: 'post', data })
}
//获取专项检查列表
export const getSpecialInspectList = (data) => {
  return request({ url: 'xhyj/task/getSpecialInspectList' + setParams(data), method: 'get' })
}
//检查内容下拉框
export const getSheetName = (data) => {
  return request({ url: 'xhyj/task/getSheetName', method: 'get' })
}
//获取检查部门
export const getCheckDept = (data) => {
  return request({ url: 'xhyj/task/getCheckDept' + setParams(data), method: 'get' })
}
//获取检查人员
export const getCheckPeople = (data) => {
  return request({ url: 'xhyj/task/getCheckPeople', method: 'get' })
}
//获取检查单位列表
export const getCheckBusiness = (data) => {
  return request({ url: 'xhyj/task/getCheckBusiness' + setParams(data), method: 'get' })
}
//*********************************************************************
//提交检查单
export const saveInspectItems = (data) => {
  return request({ url: 'xhyj/task/saveInspectItems', method: 'post', data })
}
//获取所有检查单
export const getInspectList = (data) => {
  return request({ url: 'xhyj/task/getInspectList', method: 'get' })
}
